//
//  KDMTabBarViewController.m
//  KouDaiMaster
//
//  Created by 范智渊 on 2018/4/18.
//  Copyright © 2018年 zzgk. All rights reserved.
//

#import "KDMTabBarViewController.h"
#import "RDVTabBarItem.h"

@interface KDMTabBarViewController ()<RDVTabBarControllerDelegate>

@end

@implementation KDMTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIViewController *home = [MainStoryboard instantiateViewControllerWithIdentifier:@"homeVC"];
    UINavigationController *homeNavi = [[UINavigationController alloc]
                                        initWithRootViewController:home];
    UIViewController *online = [MainStoryboard instantiateViewControllerWithIdentifier:@"onlineVC"];
    UINavigationController *onlineNavi = [[UINavigationController alloc]
                                          initWithRootViewController:online];
    UIViewController *me = [MainStoryboard instantiateViewControllerWithIdentifier:@"meVC"];
    UINavigationController *meNavi = [[UINavigationController alloc]
                                      initWithRootViewController:me];
    UIViewController *offline = [MainStoryboard instantiateViewControllerWithIdentifier:@"offLine"];
    UINavigationController *offLoneNavi = [[UINavigationController alloc]
                                           initWithRootViewController:offline];

    self.viewControllers = @[homeNavi,onlineNavi,offLoneNavi,meNavi];
    [self.tabBar setHeight:55];
    self.selectedViewController = homeNavi;
    [self customizeTabBarForController];

}


- (void)customizeTabBarForController {

    NSArray *tabBarImgName = @[@"home",@"online",@"offLine",@"me"];
    NSArray *tabBarTitles = @[@"主页",@"线上",@"线下",@"我的"];
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[self tabBar] items]) {

        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@-select",tabBarImgName[index]]];
        UIImage *unselectedimage = [UIImage imageNamed:tabBarImgName[index]];

        item.title = tabBarTitles[index];
        item.selectedTitleAttributes =  @{ NSFontAttributeName: [UIFont systemFontOfSize:12],
                                           NSForegroundColorAttributeName: FZYColor(250, 95, 53),};
        item.unselectedTitleAttributes = @{
                                           NSFontAttributeName: [UIFont systemFontOfSize:12],
                                           NSForegroundColorAttributeName: FZYColor(142, 142, 147),
                                           };
        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
        index++;
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
